/*
 * Selling Partner API for Listings Items
 * The Selling Partner API for Listings Items (Listings Items API) provides programmatic access to selling partner listings on Amazon. Use this API in collaboration with the Selling Partner API for Product Type Definitions, which you use to retrieve the information about Amazon product types needed to use the Listings Items API.  For more information, see the [Listings Items API Use Case Guide](https://developer-docs.amazon.com/sp-api/docs/listings-items-api-v2021-08-01-use-case-guide).
 *
 * OpenAPI spec version: 2021-08-01
 *
 *
 * NOTE: This class is auto generated by the swagger code generator program.
 * https://github.com/swagger-api/swagger-codegen.git
 * Do not edit the class manually.
 */

package software.amazon.spapi.models.listings.items.v2021_08_01;

import com.google.gson.TypeAdapter;
import com.google.gson.annotations.JsonAdapter;
import com.google.gson.annotations.SerializedName;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
import io.swagger.v3.oas.annotations.media.Schema;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

/** The relationship details for a listing item. */
@Schema(description = "The relationship details for a listing item.")
public class ItemRelationship {
    @SerializedName("childSkus")
    private List<String> childSkus = null;

    @SerializedName("parentSkus")
    private List<String> parentSkus = null;

    @SerializedName("variationTheme")
    private ItemVariationTheme variationTheme = null;

    /** The type of relationship. */
    @JsonAdapter(TypeEnum.Adapter.class)
    public enum TypeEnum {
        @SerializedName("VARIATION")
        VARIATION("VARIATION"),
        @SerializedName("PACKAGE_HIERARCHY")
        PACKAGE_HIERARCHY("PACKAGE_HIERARCHY");

        private String value;

        TypeEnum(String value) {
            this.value = value;
        }

        public String getValue() {
            return value;
        }

        @Override
        public String toString() {
            return String.valueOf(value);
        }

        public static TypeEnum fromValue(String input) {
            for (TypeEnum b : TypeEnum.values()) {
                if (b.value.equals(input)) {
                    return b;
                }
            }
            return null;
        }

        public static class Adapter extends TypeAdapter<TypeEnum> {
            @Override
            public void write(final JsonWriter jsonWriter, final TypeEnum enumeration) throws IOException {
                jsonWriter.value(String.valueOf(enumeration.getValue()));
            }

            @Override
            public TypeEnum read(final JsonReader jsonReader) throws IOException {
                Object value = jsonReader.nextString();
                return TypeEnum.fromValue((String) (value));
            }
        }
    }

    @SerializedName("type")
    private TypeEnum type = null;

    public ItemRelationship childSkus(List<String> childSkus) {
        this.childSkus = childSkus;
        return this;
    }

    public ItemRelationship addChildSkusItem(String childSkusItem) {
        if (this.childSkus == null) {
            this.childSkus = new ArrayList<String>();
        }
        this.childSkus.add(childSkusItem);
        return this;
    }

    /**
     * Identifiers (SKUs) of the related items that are children of this listing item.
     *
     * @return childSkus
     */
    @Schema(description = "Identifiers (SKUs) of the related items that are children of this listing item.")
    public List<String> getChildSkus() {
        return childSkus;
    }

    public void setChildSkus(List<String> childSkus) {
        this.childSkus = childSkus;
    }

    public ItemRelationship parentSkus(List<String> parentSkus) {
        this.parentSkus = parentSkus;
        return this;
    }

    public ItemRelationship addParentSkusItem(String parentSkusItem) {
        if (this.parentSkus == null) {
            this.parentSkus = new ArrayList<String>();
        }
        this.parentSkus.add(parentSkusItem);
        return this;
    }

    /**
     * Identifiers (SKUs) of the related items that are parents of this listing item.
     *
     * @return parentSkus
     */
    @Schema(description = "Identifiers (SKUs) of the related items that are parents of this listing item.")
    public List<String> getParentSkus() {
        return parentSkus;
    }

    public void setParentSkus(List<String> parentSkus) {
        this.parentSkus = parentSkus;
    }

    public ItemRelationship variationTheme(ItemVariationTheme variationTheme) {
        this.variationTheme = variationTheme;
        return this;
    }

    /**
     * Get variationTheme
     *
     * @return variationTheme
     */
    @Schema(description = "")
    public ItemVariationTheme getVariationTheme() {
        return variationTheme;
    }

    public void setVariationTheme(ItemVariationTheme variationTheme) {
        this.variationTheme = variationTheme;
    }

    public ItemRelationship type(TypeEnum type) {
        this.type = type;
        return this;
    }

    /**
     * The type of relationship.
     *
     * @return type
     */
    @Schema(example = "VARIATION", required = true, description = "The type of relationship.")
    public TypeEnum getType() {
        return type;
    }

    public void setType(TypeEnum type) {
        this.type = type;
    }

    @Override
    public boolean equals(java.lang.Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        ItemRelationship itemRelationship = (ItemRelationship) o;
        return Objects.equals(this.childSkus, itemRelationship.childSkus)
                && Objects.equals(this.parentSkus, itemRelationship.parentSkus)
                && Objects.equals(this.variationTheme, itemRelationship.variationTheme)
                && Objects.equals(this.type, itemRelationship.type);
    }

    @Override
    public int hashCode() {
        return Objects.hash(childSkus, parentSkus, variationTheme, type);
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append("class ItemRelationship {\n");

        sb.append("    childSkus: ").append(toIndentedString(childSkus)).append("\n");
        sb.append("    parentSkus: ").append(toIndentedString(parentSkus)).append("\n");
        sb.append("    variationTheme: ")
                .append(toIndentedString(variationTheme))
                .append("\n");
        sb.append("    type: ").append(toIndentedString(type)).append("\n");
        sb.append("}");
        return sb.toString();
    }

    /** Convert the given object to string with each line indented by 4 spaces (except the first line). */
    private String toIndentedString(java.lang.Object o) {
        if (o == null) {
            return "null";
        }
        return o.toString().replace("\n", "\n    ");
    }
}
